package com.tonghui.dm.io;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.ArrayList;

import org.apache.hadoop.io.Writable;

public class ArrayListWritable extends ArrayList<String> implements Writable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public void readFields(DataInput in) throws IOException {
		int size = in.readInt();
		for(int i = 0 ; i < size ; i ++){
			add(in.readUTF());
		}
	}

	@Override
	public void write(DataOutput out) throws IOException {
		int size = size();
		out.writeInt(size);
		for(int i = 0 ; i < size ; i ++){
			out.writeUTF(get(i));
		}
	}
	
	public static void main(String[] args) {
		ArrayListWritable arrayListWritable = new ArrayListWritable();
	}

}
